package com.example.administrator.himalaya.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.Button;

import com.example.administrator.himalaya.R;
import com.example.administrator.himalaya.entity.castentity.Entity;

import java.util.List;

public class MyAdapter1 extends BaseAdapter {
    private Context context;
    private List<Entity.DataEntity.CategoriesEntity> datas;
    private LayoutInflater inflarter;

    public MyAdapter1(Context context, List<Entity.DataEntity.CategoriesEntity> datas) {
        this.context = context;
        this.datas = datas;
        inflarter = LayoutInflater.from(context);
    }

    @Override
    public int getCount() {
        return datas.size();
    }

    @Override
    public Object getItem(int i) {
        return null;
    }

    @Override
    public long getItemId(int i) {
        return 0;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        ViewHolder holder;
        if(convertView == null){
            convertView = inflarter.inflate(R.layout.main, parent, false);
            holder = new ViewHolder(convertView);
            convertView.setTag(holder);
        }else {
            holder = (ViewHolder) convertView.getTag();
        }
        String img = datas.get(position).getName();
        holder.mTextView.setText(img);
        return convertView;
    }
    static class  ViewHolder{
        Button mTextView;


        public ViewHolder(View view) {
           mTextView = (Button) view.findViewById(R.id.button);
        }
    }
}
